package operation;
import book.Book;
import book.BookList;
import java.util.Scanner;
import Find.*;

public class FindBook implements IOperation{
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("1.按书名查找");
        System.out.println("2.按分类查找");
        System.out.println("3.按作者查找");
        System.out.println("请输入你查找的方式");
        int choice = scanner.nextInt();
        scanner.nextLine();
        System.out.println("请输入你要查找的信息");
        Find find = Book.findMethods[choice];
        find.setAid(scanner.nextLine());
        int num = 0;
        for(int i = 0; i < bookList.getNum(); i++) {
            if(find.findIn(bookList.getBook(i))) {
                System.out.println(bookList.getBook(i));
                num++;
            }
        }
        System.out.println("一共找到" + num + "本与" + find.getAid() + "相关的书籍");
    }
}
